<!--{template admin/header}-->
<body id="homepage">
    <div id="breadcrumb">
        <ul>
            <li><img src="static/img/icons/icon_breadcrumb.png"
                     alt="Location" /></li>
            <li><strong>位置:</strong></li>
            <li><a href="admin.php">主页</a> - 商店管理</li>
        </ul>
    </div>
    <div id="rightside" >
        <div class="contentcontainer">
            <div class="headings altheading">
            <h3><span class="nav_left">{$goods_name}商店</span></h3>
			  </div>
                <div class="paper-head">
				<div>			
				
					<span class="nav_right"><a href="#add{$goods}" role="button" class="btn btn-primary btn-middle" data-toggle="modal">添加</a></span>
				
					<div id="add{$goods}" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel_add{$goods}" aria-hidden="true" style="width:443px">
					<form id="shop{$goods}" >
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
							<h3 id="myModalLabel_add{$goods}">添加{$goods_name}包</h3>
						</div>
						<div class="modal-body nav-category" style="max-height:800px;">
							<div class="input-prepend">
								<span class="add-on">id号</span>
								<input class="span4" id="prependedInput" type="text" placeholder="id" name="id">
							</div>
							<div class="input-prepend">
								<span class="add-on">名称</span>
								<input class="span4" id="prependedInput" type="text" placeholder="name" name="name">
							</div>
							<div class="input-prepend">
								<span class="add-on">介绍</span>
								<input class="span4" id="prependedInput" type="text" placeholder="介绍" name="desc">
							</div>								
					   </div>
					   <div class="modal-footer">
					   		<input type="hidden" name="ac" value="shop"/>
					   		<input type="hidden" name="op" value="add{$goods}"/>
						    <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
						    <button type="button" id="submit" class="btn btn-primary">添加</button>
					   </div>
					  </form>
					</div>
					</div>
				</div>
          
            <div class="contentbox">
                <table width="100%" class="table table-striped">
                    <thead>
                        <tr>
                        	<th>id</th>
                            <th>封面</th>
                            <th>名称</th>
                            <th>任务</th>
                            <th>价格</th>
                            <th>状态</th>
                            <th>下载量</th>
                            <th>编辑</th>
                        </tr>
                    </thead>
                    
                    <tbody>
                  
                    	<!--{loop $list $value}-->
					<tr>
						<td>
						<!--{$value[id]}-->							
						</td>
						<td><img height="40px" width="40px" src="{$value[cover_s]}"/></td>
						<td><!--{$value[name]}--></td>
						<td>
							<!--{if $value[task][type]}-->
							<span class="label label-important">
							<!--{$taskTypeArr[$value[task][type]]}-->限制,
							<!--{$value[task][desc]}-->
							</span>
							<!--{else}-->
							<span class="label">无任务限制</span>
							<!--{/if}-->
						</td>
						<td>
							<!--{if $value[price_final] > 0}-->
								<span class="badge badge-important">{$value[price_final]}</span> 金币
							<!--{else}-->
								免费
							<!--{/if}-->
						</td>
						<td>
							<!--{if $value[status] == 0}-->
								<i class="icon-ok"></i>
							<!--{else}-->
								<i class="icon-remove-circle"></i>
							<!--{/if}-->
						</td>
						<td><!--{$value['sale_amount']}--></td>	
						
						<td>
						<a href="admin.php?ac=shop&op=get{$goods}Detail&id={$value[id]}" target="_blank" role="button" class="btn btn-success btn-middle" >编辑</a>
						<span class="nav_right"><a href="#addpack{$value[id]}" role="button" class="btn btn-primary btn-middle" data-toggle="modal">打包</a>
						<!--{if empty($value[download_url])}-->
								未打包
						<!--{else}-->
								已打包
						<!--{/if}-->
						</span>
						</td>
						<div>											
						<div id="addpack{$value[id]}" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel_addpack{$goods}" aria-hidden="true">
						<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
								<h3 id="myModalLabel_add{$goods}">添加{$goods_name}包</h3>
						</div>
						
						<form  class="form-inline" role="form" method="post" action='admin.php?ac=pack&op=submit' enctype="multipart/form-data">									
						<div class="modal-body nav-category" style="max-height:800px;">
						       <div class="form-group">
							      <label for="id">ID
							      <input type="text" class="form-control" name="id" placeholder="id" value={$value[id]} >
							      </label>
							   </div>
							   <div class="form-group">
							      <label for="name">拼音名称
							      <input type="text" class="form-control" name="name" placeholder="请输入名称拼音">
							      </label>
							   </div>
							   <div class="form-group">
							      <label for="inputfile">选择包文件
							      <input type="file" id="inputfile" name="package">		
							      </label>			     
							   </div>
						  </div>
						   <div class="modal-footer">	
						   <input type="hidden" name="type" value="{$packtype}">					  
						   <button type="submit" class="btn btn-default" >提交</button>
						   </div>
						</form>
						</div>
					   </div>
					</tr>
					<!--{/loop}-->
				
                    </tbody>
                
                </table>
               
                
                <div style="clear: both;"></div>
            </div>
        </div>
    </div>
    <!--{template admin/leftside}-->
    <!--{template admin/footer}-->
   
    <script type="text/javascript">
    		$(document).on('click','#submit',function(){
    				//var state ={0:'增加失败',1:'增加成功'};    			
    				$.ajax({
    						type:'GET',
    						url:'shop.php',
    						data:$('#shop{$goods}').serialize(),
	   						success:function(data){
	   							//alert(state[data]);	   
	   						    window.location.href="admin.php?ac=shop&op=get{$goods}List";
	   													
	   						}
    				});   			
    		})

	</script>